#!/usr/bin/env bash

# Show the Slurm hidden partitions

# Author: Ole H. Nielsen, Technical University of Denmark
# E-mail: Ole.H.Nielsen@fysik.dtu.dk
# Home page: https://github.com/OleHolmNielsen/Slurm_tools

# Identify any hidden partitions (see slurm.conf man-page)
export hidden_partitions="`diff <(sinfo --hide -o %P) <(sinfo --all -o %P) | awk '$1==">" {printf("%s,", $2)}'`"

if test -n "$hidden_partitions"
then
	echo "Slurm hidden partitions: $hidden_partitions" | sed 's/,/ /g'
	sinfo -p "$hidden_partitions" $@
fi

# Identify any root-only partitions (see slurm.conf man-page)
export root_partitions="`sinfo --all --noheader -o "%P %r" | grep yes | awk '{printf("%s,", $2)}'`"

if test -n "$root_partitions"
then
	echo
	echo "Slurm root-only partitions: $root_partitions" | sed 's/,/ /g'
	sinfo -p "$root_partitions" $@
fi
